Skip to content

feat(nx-plugin): enforce module boundaries on new arch (release backport)#16999

Merged
lewisd5 merged 6 commits intoreleasefrom
ci/nx-enforce-module-boundaries-new-arch-release
Apr 30, 2026
Merged

feat(nx-plugin): enforce module boundaries on new arch (release backport)#16999
lewisd5 merged 6 commits intoreleasefrom
ci/nx-enforce-module-boundaries-new-arch-release

Conversation

@ysitbon
Copy link
Copy Markdown
Contributor

@ysitbon ysitbon commented Apr 30, 2026

✅ Checklist

  • npx changeset was attached. (intentionally dropped — same as the develop PR feat(nx-plugin): enforce module boundaries on new arch #16803; tooling-only change with no published-package behavior delta)
  • Covered by automatic tests. 23 node --test assertions (8 project-tags + 15 boundary validator). Validator green on the release tree (no pre-existing violations).
  • Impact of the changes:
    • New enforce-boundaries job in .github/workflows/build-and-test-pr.yml calling the new .github/workflows/test-boundaries-reusable.yml, gated on PRs touching domain/, shared/, or features/.
    • New pnpm lint:boundaries script for local verification.
    • Zero runtime behavior change for any published package.

📝 Description

Backport of #16803 (LIVE-29780) to release. Same six commits cherry-picked in order:

  1. feat(nx-plugin): infer boundary tags for new-arch packages
  2. feat(nx-plugin): enforce module boundaries via project graph
  3. chore: address PR review — de-dup tag inference, dedicated boundary check workflow
  4. fix(nx-plugin): dedupe boundary violations per source/target edge
  5. chore: restore workflow pin version to develop
  6. chore: delete unecessary changeset

Conflicts resolved during cherry-pick (release lags develop by ~540 commits):

  • .github/workflows/test-libs-reusable.yml — release does not yet have the Check export rules step (dcb1947f75 on develop). Kept only the boundary-related lines from this PR; left Check export rules for a future cherry-pick if needed.
  • .github/workflows/build-and-test-pr.yml — release does not yet have the test-shared / test-domain jobs. Inserted the new enforce-boundaries job between test-features and test-design-system on the existing release shape.

Tag taxonomy, dependency constraints, enforcement strategy, and forward-compat path are identical to the develop PR — see #16803 and the Jira ticket for the full plan and research notes.

❓ Context

CI note: enforce-boundaries job calls test-boundaries-reusable.yml@develop. That workflow file does not yet exist on develop (still in #16803). Until #16803 merges, this job will fail to resolve the workflow. After #16803 lands, retrigger CI here.

ysitbon added 6 commits April 30, 2026 12:14
Extends the project-tags plugin so every package under domain/, shared/,
and features/ carries the tags that LIVE-29780's upcoming module-boundary
validator will rely on:

- domain/entity/*  -> scope:domain + type:domain-entity
- domain/api/*     -> scope:domain + type:domain-api
- shared/*         -> scope:shared
- features/*       -> scope:features (unchanged)

Legacy libs/, apps/, e2e/, and tools/ inference is untouched. 8 node:test
assertions lock both the new branches and the legacy regression paths.

Refs: LIVE-29780
Adds a linter-agnostic validator that walks the Nx project graph and
verifies every workspace -> workspace edge against the new-arch layering
rules. Runs via @nx/devkit's createProjectGraphAsync, no ESLint involved
(the repo is migrating to oxlint; 143/149 packages already use it).

Rules (DEP_CONSTRAINTS, defined in tools/nx-plugins/enforce-boundaries/
constraints.js):

- scope:shared       can depend on scope:shared only (leaf layer)
- scope:domain       can depend on scope:domain + scope:shared
- scope:features     can depend on scope:features + scope:domain + scope:shared
- type:domain-entity can depend on type:domain-entity + scope:shared
- type:domain-api    can depend on type:domain-entity + type:domain-api + scope:shared
…heck workflow

inferTags: drop the duplicate domain/ and shared/ blocks. The
type-tag-aware blocks higher up already emit scope:domain /
scope:shared (alongside type:domain-entity / type:domain-api),
so behavior is preserved — just clearer to read.

CI: extract the boundary check into its own reusable workflow at
.github/workflows/test-boundaries-reusable.yml and call it from
build-and-test-pr.yml as a dedicated enforce-boundaries job, gated
on PRs touching domain/, shared/, or features/. Removes the now-
redundant step from test-libs-reusable.yml.

The new workflow is temporarily called via
@ci/nx-enforce-module-boundaries-new-arch so this PR can prove it
runs end-to-end. MUST be flipped back to @develop before merge.

Refs: LIVE-29780
A source project can match multiple depConstraints (e.g. a
type:domain-api project also has scope:domain). Before this fix
findViolations emitted one violation per matching rule, so the same
forbidden edge could surface twice in CI output and inflate the
violation count.

Now keyed by (sourceName, target): one entry per offending edge with
the failing source tags accumulated. Output formatting joins the
source tags with a comma. Adds a node:test case covering the multi-
tag dedup; existing single-tag tests adjusted from sourceTag (string)
to sourceTags (array).

Refs: LIVE-29780
@ysitbon ysitbon requested a review from a team as a code owner April 30, 2026 10:24
@live-github-bot live-github-bot Bot added tools Has changes in tools automation CI/CD stuff labels Apr 30, 2026
@lewisd5 lewisd5 merged commit 4d2e0d6 into release Apr 30, 2026
31 checks passed
@lewisd5 lewisd5 deleted the ci/nx-enforce-module-boundaries-new-arch-release branch April 30, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation CI/CD stuff tools Has changes in tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants